package cn.miao.exception;

import cn.hutool.core.text.CharSequenceUtil;

/**
 * 封装错误码
 *
 * @author MiaoDaWei
 * @date 2021/11/23
 */
public enum ErrorCode {
    //不可为空的错误码,前三位可以代表为是哪个微服务 后三位比如具体的错误码
    CODE_100_NULL_COMPANYNAME("100100", "公司名不可为空"),
    CODE_101_FORMAT_INVALID_PHONE("100101", "无效的手机格式"),
    CODE_102_EXIST_COMPANYNAME("100102", "公司名已经被注册"),
    CODE_103_SYSTEM_EXCEPTION("100103", "系统异常,正在殴打后端程序员!");

    //错误码
    private final String code;
    //错误信息
    private final String message;

    ErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public String getCodeAndMessage(){
        return CharSequenceUtil.format("{}【{}】", this.message, this.code);
    }
}
